package model;


import utils.PriceUtils;
import java.util.*;

public class   Order {
    private int id;//订单id
    private String code;//订单号
    private int product_id;//商品id
    private float price;//商品价格
    private int receiver_id;// 卖家id
    private int proxy_id;//代取id
    private String phone_number;// 联系电话
    private boolean status;//1未完成订单，0已完成
    private User user;
    private Product product;


    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) { this.code = code; }
    public int getProduct_id() { return product_id; }
    public void setProduct_id(int product_id) { this.product_id = product_id; }
    public float getPrice() { return price; }
    public void setPrice(float price) {
        this.price = price;
    }
    public int getReceiver_id() { return receiver_id; }
    public void setReceiver_id(int receiver_id) { this.receiver_id = receiver_id; }
    public int getProxy_id() { return proxy_id; }
    public void setProxy_id(int proxy_id) { this.proxy_id = proxy_id; }
    public String getPhone_number() { return phone_number; }
    public void setPhone_number(String phone_number) { this.phone_number = phone_number; }
    public User getUser() { return user; }
    public void setUser(User user) { this.user = user; }
    public boolean isStatus() { return status; }
    public void setStatus(boolean status) { this.status = status; }
//    private Map<Integer,OrderItem> itemMap = new HashMap<Integer,OrderItem>();
//    private List<OrderItem> itemList = new ArrayList<OrderItem>();
    public Product getProduct() { return product; }
    public void setProduct(Product product) { this.product = product; }

    public Order() {
        super();
    }

//    public void setUsername(String username) {
//        user = new User();
//        user.setUsername(username);
//    }
//    public void addGoods(Product g) {
//        if(itemMap.containsKey(g.getId())) {
//            OrderItem item = itemMap.get(g.getId());
//            item.setAmount(item.getAmount()+1);
//        }else {
//            OrderItem item = new OrderItem(g.getPrice(),1,g,this);
//            itemMap.put(g.getId(), item);
//        }
//        //若是此goods已经加入过订单，则只需让数量+1即可
//        price = PriceUtils.add(price, g.getPrice());
//    }

//    public List<OrderItem> getItemList() {
//        return itemList;
//    }
//
//    public void setItemList(List<OrderItem> itemList) {
//        this.itemList = itemList;
//    }
//
//    public void lessen(int goodsid) {
//        if(itemMap.containsKey(goodsid)) {
//            OrderItem item = itemMap.get(goodsid);
//            item.setAmount(item.getAmount()-1);
//            amount--;
//            buy_price = PriceUtils.subtract(buy_price, item.getPrice());
//            if(item.getAmount()<=0) {
//                itemMap.remove(goodsid);
//            }
//        }
//    }
//    public void delete(int goodsid)
//    {
//        if(itemMap.containsKey(goodsid)) {
//            OrderItem item = itemMap.get(goodsid);
//            buy_price = PriceUtils.subtract(buy_price, item.getAmount()*item.getPrice());
//            amount-=item.getAmount();
//            itemMap.remove(goodsid);
//        }
//    }

//    public Map<Integer, OrderItem> getItemMap() {
//        return itemMap;
//    }
//
//    public void setItemMap(Map<Integer, OrderItem> itemMap) {
//        this.itemMap = itemMap;
//    }


}
